{if $GLOBALS.is_ajax || $smarty.get.ajax_submit}

	{foreach from=$errors key=key item=error}
		{if $key == 'NOT_SUPPORTED_VIDEO_FORMAT' || $key == 'NOT_ACCEPTABLE_FILE_FORMAT'}
			<p class="error">[[Not supported video format]]</p>
		{else}
			<p class="error">{$key}</p>
		{/if}
	{/foreach}

	{if $value.file_url}
	<div id="user_video_{$id}">
		<div>
		{$value.file_name} ({$filesize|string_format:"%.2f"} {$size_token}) |
			<a class="delete_profile_video"
			   form_token="{$form_token}"
			   field_id="{$id}"
			   file_id="{$value.file_id}"
			   href="{$GLOBALS.site_url}/users/delete-uploaded-file/?field_id={$id}&form_token={$form_token}">[[Remove]]</a>

		</div>
		<br />
	</div>

	{/if}


	<input id="autoloadFileSelect_{$id}"
		   field_id="{$id}"
		   field_action="upload_profile_video"
		   field_target="video_field_content_{$id}"
		   type="file"
		   name="{if $complexField}{$complexField}[{$id}][{$complexStep}]{else}{$id}{/if}"
		   class="inputVideo autouploadField {if $complexField}complexField{/if}"
		   {if $value.file_url}style="display:none;"{/if} />

	<input type="hidden" name="user_group_id" value="{if isset($GLOBALS.current_user.group.id)}{$GLOBALS.current_user.group.id}{else}{$params.user_group_id}{/if}" />

{else}

	<div id="video_field_content_{$id}">

	{if $value.file_url}
	<div id="user_video_{$id}">
		<div id="video_container"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div>
		<script type="text/javascript" src="{$GLOBALS.site_url}/files/video/swfobject.js"></script>
		<div>
			<script type="text/javascript">
				var s1 = new SWFObject("{$GLOBALS.site_url}/files/video/player.swf","ply","250","250","9","#FFFFFF");
				s1.addParam("allowscriptaccess","always");
				s1.addParam("allowfullscreen","true");
				s1.addParam("wmode", "opaque");
				s1.addParam("flashvars","file={$value.file_url}&image={$value.file_url|regex_replace:"/flv/":"png"}&fullscreen=true");
				s1.write("video_container");
			</script>
			<br />
			<a class="delete_profile_video"
			   form_token="{$form_token}"
			   field_id="{$id}"
			   file_id="{$value.file_id}"
			   href="{$GLOBALS.site_url}/users/delete-uploaded-file/?field_id={$id}&form_token={$form_token}">[[Remove]]</a>

		</div>
		<br />
	</div>
	{/if}


		<input id="autoloadFileSelect_{$id}"
			   field_id="{$id}"
			   field_action="upload_profile_video"
			   field_target="video_field_content_{$id}"
			   type="file"
			   name="{if $complexField}{$complexField}[{$id}][{$complexStep}]{else}{$id}{/if}"
			   class="inputVideo autouploadField {if $complexField}complexField{/if}"
			   {if $value.file_url}style="display:none;"{/if} />

		<input type="hidden" name="user_group_id" value="{if isset($GLOBALS.current_user.group.id)}{$GLOBALS.current_user.group.id}{else}{$params.user_group_id}{/if}" />

	</div>


	<script>
		{literal}

		$(".delete_profile_video").live('click', function() {
			var fileId  = $(this).attr('file_id');
			var fieldId = $(this).attr('field_id');
			var formToken = $(this).attr('form_token');
			var url     = window.location.host + '/system/miscellaneous/ajax_file_upload_handler/';
			var params = {
				'ajax_action': 'delete_profile_video',
				'field_id' : fieldId,
				'file_id' : fileId,
				'user_group_id' : '{/literal}{if isset($GLOBALS.current_user.group.id)}{$GLOBALS.current_user.group.id}{else}{$params.user_group_id}{/if}{literal}',
				'form_token' : formToken
			};

			var preloader = $(this).after( getPreloaderCodeForFieldId(fieldId) );
			$.get(url, params, function(data){
				if (data.result == 'success') {
					$("#autoloadFileSelect_" + fieldId).show();
					$("#user_video_" + fieldId).empty();
				}
				$(preloader).remove();
			}, 'json');
			// prevent link redirect
			return false;
		});


		$(function() {
			{/literal}
			getProfileVideoData('{$id}', '{$form_token}');
			{literal}
		});


		{/literal}
	</script>

{/if}